<? include "./configs/session_check.php";?>
<? include "./configs/config.php";?>
<? include "select.class.php"; ?>
<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
	
	<title>.:: Task Tracker ::.</title>

<? include "./configs/includes.php";?>
    
    <script type="text/javascript">
		  $(document).ready(function() {
			$("#accordion").accordion({ collapsible: true, active: false });
			 $("#TaskTable").load("./TaskName.php");
			 
			 
			 $("select#type").attr("disabled","disabled");
			 
			 
				$("select#language").change(function(){
				$("select#Project").attr("disabled","disabled");
				$("select#Project").html("<option>wait...</option>");
				
				var id = $('#language :selected').text();
				$.post("SelectProject.php", {id:id}, function(data){
					$("select#Project").removeAttr("disabled");
					$("select#Project").html(data);
				});
        });
		$("select#Project").change(function(){
				
				var id = $('#Project :selected').val();
				$.post("TaskName.php", {id:id}, function(data){
					$("#TaskTable").html(data);
				});
        });
		  });
  </script>
<meta charset="UTF-8"></head>

<body>

	<div id="container">
		<div id="bgwrap">
			<div id="primary_left">
        
				<? include "./configs/left.php";?>
                 <!-- navigation menu end -->
			</div> <!-- sidebar end -->

			<div id="primary_right">
				<div class="inner">
				
				<? include "./configs/top.php";?>
					
					
					
					<h1><label>Section:</label><select name="Section" id="language" class="dropdown">
                    			<option value="Select">Select an option</option>
								<?php echo $opt->ShowSection(); ?>
							</select>
                           <label>Project: </label> <select name="Section" id="Project" class="dropdown">
                           <option value="Select">Select an option</option>
							</select></h1>
                  
					<p></p>
					
				<div id="TaskTable"></div>
                
					
				
				</div> <!-- inner -->
			</div> <!-- primary_right -->
		</div> <!-- bgwrap -->
        <? include "./configs/footer.php";?>
	</div> <!-- container -->
         <script type="text/javascript">
        $(document).ready(function(){
	$('#submit').click(function() {				
		$.ajax({
			type : 'POST',
			url : 'ProcessProject.php',
			dataType : 'json',
			data: {
				ProjectTitle : $("#ProjectTitle").val(),
                DeadLine : $('#DeadLine').val(),
                ProjectManager : $('#ProjectManager').val(),
                Department : $('#Department').val(),
				Section : $('#Section').val()
			},
			success : function(data){
				
				$('#demoForm').show(100);
				$('#message').removeClass().addClass((data.error === true) ? 'error' : 'success')
					.text(data.msg).show(100);
					
				//$('#price').val(data.price);
				if (data.error === true)
					$('#demoForm').show(100);
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				
				$('#message').removeClass().addClass('error')
					.text('There was an error.').show(500);
				$('#demoForm').show(100);
			}
		});
		
		return false;
	});
	$('#submittask').click(function() {				
		$.ajax({
			type : 'POST',
			url : 'ProcessTask.php',
			dataType : 'json',
			data: {
				ProjectID : $("#ProjectID").val(),
                AssigneTo : $('#AssigneTo').val(),
                TaskTitle : $('#TaskTitle').val(),
				TaskDetails : $('#TaskDetails').val(),
                MinutesRequired : $('#MinutesRequired').val(),
				LineManager : $('#LineManager').val(),
				Priority : $('#Priority').val()
			},
			success : function(data){
				
				$('#messagetask').removeClass().addClass((data.error === true) ? 'error' : 'success')
					.text(data.msg).show(100);
				
				//$('#price').val(data.price);
				
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				
				$('#messagetask').removeClass().addClass('error')
					.text('There was an error.').show(500);
				
			}
		});
		
		return false;
	});
		$('#submitnote').click(function() {				
		$.ajax({
			type : 'POST',
			url : 'ProcessNote.php',
			dataType : 'json',
			data: {
				TaskID : $("#TaskID").val(),
                NoteTitle : $('#NoteTitle').val(),
                NoteDetails : $('#NoteDetails').val()
			},
			success : function(data){
				
				$('#messagenote').removeClass().addClass((data.error === true) ? 'error' : 'success')
					.text(data.msg).show(100);
				//$('#price').val(data.price);
				
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				
				$('#messagenote').removeClass().addClass('error')
					.text('There was an error.').show(500);
				
			}
		});
		
		return false;
	});
	$('#clockin').click(function() {				
		$.ajax({
			type : 'POST',
			url : 'ProcessClockin.php',
			dataType : 'json',
			data: {
				userid : $("#userid").val()
			},
			success : function(data){
				
				
					$('#formclockin').hide(500);
					$('#formclockout').show(100);
				//$('#price').val(data.price);
				if (data.error === true)
					$('#formclockin').show(100);
				
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				
				$('#messageclockin').removeClass().addClass('error')
					.text('There was an error.').show(500);
				
			}
		});
		
		return false;
	});
	$('#clockout').click(function() {				
		$.ajax({
			type : 'POST',
			url : 'ProcessClockout.php',
			dataType : 'json',
			data: {
				userid : $("#userid").val()
			},
			success : function(data){
				
				
				//$('#price').val(data.price);
				$('#formclockin').show(100);
				$('#formclockout').hide(100);
				$('#logintimee').hide(200);
				
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				
				$('#messageclockout').removeClass().addClass('error')
					.text('There was an error.').show(500);
				
			}
		});
		
		return false;
	});
});
        </script>
</body>
</html>
